<?php

namespace app\admin\controller\system;

use app\common\controller\AdminController;
use app\common\lib\Show;
use app\common\lib\Status;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;


/**
 * @ControllerAnnotation(title="城市")
 */
class City extends AdminController
{

    use \app\admin\traits\Curd;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->model = new \app\common\model\SystemCity();

    }

    /**
     * @NodeAnotation(title="根据省编号查询所有城市")
     * @return array|\think\response\Json
     * @throws \think\Exception
     */
    public function getProvinceByCityNameAndValue()
    {
        $province = $this->request->param('province', '', 'trim');
        $where = [
            'father' => $province
        ];
        $row = $this->model->getBaseByNormalList($where, 'city_id as value,city as name');
        return Show::json_show(Status::mini_normal, 'ok', $row);
    }

}